package com.wonderplay.warlord.module.combat;

import java.util.List;


public class MatrixAdaptor extends MainMatrix {

	private int[][] tempMatrix;

	public MatrixAdaptor(int width, int height, int eliminateNum, int unitTypeNum) {
		super(width, height, eliminateNum, unitTypeNum);
		
		tempMatrix = new int[width][height];
	}

//	/**
//	 * @param x
//	 * @param y
//	 * @param switchType
//	 * @return if can eliminate after move
//	 */
//	public boolean switchUnitFake(int x, int y, int switchType) {
//		List<EliminateUnits> unitsList = searchForEliminate(x, y, switchType);
//		return unitsList.size() > 0;
//	}

	public void switchUnit(int x, int y, int switchType) {
		int temp;
		switch (switchType) {
		case SWITCH_UP:
			temp = unitMatrix[x][y];
			unitMatrix[x][y] = unitMatrix[x][y - 1];
			unitMatrix[x][y - 1] = temp;
			break;
		case SWITCH_DOWN:
			temp = unitMatrix[x][y];
			unitMatrix[x][y] = unitMatrix[x][y + 1];
			unitMatrix[x][y + 1] = temp;
			break;
		case SWITCH_LEFT:
			temp = unitMatrix[x][y];
			unitMatrix[x][y] = unitMatrix[x - 1][y];
			unitMatrix[x - 1][y] = temp;
			break;
		case SWITCH_RIGHT:
			temp = unitMatrix[x][y];
			unitMatrix[x][y] = unitMatrix[x + 1][y];
			unitMatrix[x + 1][y] = temp;
			break;
		}
	}
	
	public int[][] getMatrix(){
		for(int i = 0; i< width; i++){
			for (int j = 0; j < height; j++){
				tempMatrix[i][j] = unitMatrix[i][j];
			}
		}
		
		return tempMatrix;
	}
}
